#ifndef _SET_DEC
#define _SET_DEC

#include <set>
#include <iterator>

namespace mylib {
	template<class type> class Set : public std::set<type> {
	public:
		Set() {}
		Set(type pos) { this->insert(pos); }
		
		Set<type> &operator+=(type pos) { this->insert(pos); return *this; }
		Set<type> &operator+=(const Set<type> &s) {  
			typename std::set<type>::const_iterator I;
			for(I=s.begin(); I!=s.end(); I++)
				this->insert(*I);
			return *this;
		}
		Set<type> &operator-=(type key) {
			typename std::set<type>::iterator I;
			if( (I=this->find(key)) != this->end() )
				this->erase(I);
			return *this;
		}
		bool exist(type &t) const{ if( find(t) != this->end() ) return true; else return false; }
		type low() const{ 
			typename std::set<type>::const_iterator I=this->begin();
			if( I!=this->end()) return *I;else return 0; 
		}
		type upper() const {
			typename std::set<type>::const_iterator I;
			if( this->begin()!=(I=this->end()) ) {
				I--;
				return *I;
			} else 
				return 0;
		}
		friend std::ostream &operator<<(std::ostream &out, const Set<type> &s) {
			for(typename Set<type>::const_iterator I=s.begin(); I!=s.end(); I++ )
				out << *I << '\t';
			return out;
		}
	};
}
#endif
